/**
 * 
 */
package org.cuatrovientos.erp.business;

import java.util.List;

import org.apache.log4j.Logger;
import org.cuatrovientos.erp.dao.DelegationDAOInterface;
import org.cuatrovientos.erp.model.Delegation;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @author natalia
 * This class implements DelegationBOInterface
 *
 */
public class DelegationBO implements DelegationBOInterface{

	// Get log4j logger
		private static final Logger logger = Logger.getLogger(DelegationBO.class);
		
		@Autowired
	    private DelegationDAOInterface delegationDAO;
		
	/**
	 * @param int id
	 * @return Delegation delegation
	 * This method returns a delegation selected by it's id
	 */
	@Override
	public Delegation selectById(int id) {
		logger.info("selectById: " + id);
		return delegationDAO.selectById(id);
	}
	
	/**
	 * @return All the delegations we have in the database
	 */
	@Override
	public List<Delegation> selectAll() {
		logger.info("selectAll: ");
		return delegationDAO.selectAll();
	}
	
	/**
	 * @return The number of delegations we have in the database
	 */
	@Override
	public List<Delegation> search(String name) {
		logger.info("search : " + name);
		return delegationDAO.search(name);
	}
	
	/**
	 * @param int id
	 * This method deletes the delegation selected by id
	 */
	@Override
	public void deleteById(int id) {
		logger.info("delete by: " + id + " id");
		delegationDAO.deleteById(id);
	}
	
	/**
	 * @param Delegation delegation
	 * This method insert a delegation in the database passed by parameter
	 */
	@Override
	public void insert(Delegation delegation) {
		logger.info("insert: " + delegation);
		delegationDAO.insert(delegation);
	}
	
	/**
	 * @param Delegation delegation
	 * This method updates a delegation passed by parameter
	 */
	@Override
	public void update(Delegation delegation) {
		logger.info("update: " + delegation);
		delegationDAO.update(delegation);
	}
	
	/**
	 * @param Delegation delegation
	 * This method deletes a delegation passed by parameter
	 */
	@Override
	public void delete(Delegation delegation) {
		logger.info("delete: " + delegation);
		delegationDAO.delete(delegation);
	}

}
